<!--
 * @Description: 
 * @Author: mmzhang
 * @Date: 2022-11-07 17:13:14
 * @LastEditTime: 2022-11-08 14:14:12
-->
<!-- 销控统计 -->
<template>
  <div class="control_statistics_page">
    <div class="flex flex-horizontal-between">
      <p class="title">销控统计</p>
      <div class="flex flex-vertical-center">
        <p class="hand view-more" @click="toBuildControl('customerVisit')"
          style="margin-left:20px;">
          管理销控<span style="margin-left:5px;">></span></p>
      </div>
    </div>
    <dt-grid ref="table" :columns="columns" :onFetch='onFetch' :height='288' :border=false />
  </div>
</template>
<script>
  import columns from './controlColumns'
  import homeMgr from '@/biz/buildingHome/home'

  export default {
    data() {
      return {
        columns: [],
        chooseTime: {}
      }
    },
    methods: {
      init(data) {
        this.chooseTime = data
        this.columns = columns.headers(this)
        this.$refs.table.fetch()
      },
      toBuildControl() {
        this.$router.push({
          name: 'buildingControl',
        })
      },
      onFetch() {
        let params = {
          buildingId: this.$dt.buildInfo().housesId,
        }
        return homeMgr.salesControlStatistics(params).then((res) => {
          let arr = []
          if (res.length > 5) {
            arr = res.splice(0, 5)
          } else {
            arr = res.splice(0, res.length)
          }
          return arr
        })
      },
    }
  }
</script>
<style lang="scss" scoped>
  .control_statistics_page {
    background-color: #fff;
    padding: 20px 15px;
    width: 49.5%;
    border-radius: 5px;

    .title {
      padding-left: 8px;
      color: #222;
      font-size: 18px;
      border-left: 2px solid #2298ff;
      font-weight: bolder;
    }

    .view-more {
      font-size: 12px;
      color: #2298ff;
    }
  }
</style>